from wtforms import StringField, PasswordField, BooleanField, SubmitField, Form
from wtforms.validators import length, email, DataRequired, Regexp


# todo RegisterRequestsForm
class RegisterRequestsForm(Form):
    phone = StringField('phone', validators=[DataRequired(), Regexp(r'^1[35789]\d{9}$', message="请输入11位手机号")])
    email = StringField('phone', validators=[DataRequired(), email()])
    password = StringField('password', validators=[
        DataRequired(),
        Regexp(r'^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,10}$', message="必须包含大小写字母和数字的组合，不能使用特殊字符，长度在 8-10 之间")
    ])
    name = StringField('name', validators=[DataRequired()])
    company_name = StringField('company_name', validators=[DataRequired()])
    address = StringField('address', validators=[DataRequired()])


# todo BossAccountForm
class BossAccountForm(Form):
    phone = StringField('phone', validators=[DataRequired(), Regexp(r'^1[35789]\d{9}$', message="请输入11位手机号")])
    email = StringField('phone', validators=[DataRequired(), email()])
    password = StringField('password', validators=[
        DataRequired(),
        Regexp(r'^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,10}$', message="必须包含大小写字母和数字的组合，不能使用特殊字符，长度在 8-10 之间")
    ])
    name = StringField('name', validators=[DataRequired()])
    company_name = StringField('company_name', validators=[DataRequired()])
    address = StringField('address', validators=[DataRequired()])
    salesman = StringField('salesman', validators=[DataRequired(message="请输入业务员")])
    commercial_specialist = StringField('commercial_specialist', validators=[DataRequired(message="请输入商务专员")])


# todo LoginForm
class LoginForm(Form):
    phone = StringField('phone', validators=[DataRequired(), Regexp(r'^1[35789]\d{9}$', message="请输入11位手机号")])
    password = StringField('password', validators=[DataRequired(), length(min=6, max=20)])


# todo UploadInformationForm
class UploadInformationForm(Form):
    applicant = StringField('applicant', validators=[DataRequired()])  # 申请人
    applicant_company = StringField('applicant_company', validators=[DataRequired()])  # 申请人公司
    phone = StringField('phone', validators=[DataRequired(), Regexp(r'^1[35789]\d{9}$', message="请输入11位手机号")])  # 下单人联系方式


# todo CompanyForm
class CompanyForm(Form):
    name = StringField('name', validators=[DataRequired()])  # 申请人
    address = StringField('address', validators=[DataRequired()])  # 申请人公司


# todo UpdatePasswdForm
class UpdatePasswdForm(Form):
    password = StringField('password', validators=[
        DataRequired(),
        Regexp(r'^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,10}$', message="必须包含大小写字母和数字的组合，不能使用特殊字符，长度在 8-10 之间")
    ])


# todo ProductForm
class ProductForm(Form):
    name = StringField('name', validators=[DataRequired(message="名字不能为空")])
    guidance_price = StringField('guidance_price', validators=[DataRequired(message="价格不能为空")])
    tax_rate = StringField('tax_rate', validators=[DataRequired(message="税率不能为空")])
    remark = StringField('remark')
